package com.test.javafaq_portal.service.impl;

import com.test.javafaq_portal.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    private IUserService userService;

    @Override
    public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException {
        UserDetails user = userService.getUserDetails(name);
//        if("jerry".equals(name)){
//            //设置jerry的详情
//            user = User.builder()
//                    .username("jerry")
//                    .password("{bcrypt}$2a$10$Pjs9HNQXx.81Rs3CE7.W6Ot0BZNnXLMfInsapg2ayHw7M4CkD9bq.")
//                    .authorities("/user/get")
//                    .build();
//        }

        return user;
    }
}
